package com.itboye.textileexpes.adapter;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.itboye.textileexpes.beans.CityBeans;
import com.itboye.textileexpres.R;
import com.itboye.textillexepres.db.AddreaCitybeans;

public class ChinaCityAdapter extends BaseAdapter {
	private LayoutInflater inflater;
	private List<CityBeans> list;

	public ChinaCityAdapter(Context context, List<CityBeans> list) {

		this.inflater = LayoutInflater.from(context);
		this.list = list;

	}

	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int position) {
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder;
		if (convertView == null) {
			convertView = inflater.inflate(R.layout.item_city, null);
			holder = new ViewHolder();
			holder.name = (TextView) convertView.findViewById(R.id.name);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}

		holder.name.setText(list.get(position).getProvince());
		return convertView;
	}

	private class ViewHolder {
		TextView name;
	}

}

